//import utils from '../../common/utils.js';
import router from '@system.router';
//import echarts from 'echarts'
import prompt from '@system.prompt'

//import * as THREE from '../../common/three/build/three.module.js';

//let uniforms,geometry,material,mesh;
//let camera, scene, renderer, labelRenderer;
//let camera = new THREE.PerspectiveCamera( 45, 500 / 500, 1, 500 );
export default {
    data: {
        title: "你好!!!",
        data1: 'default',
        data2: {
          data3: [1, 2, 3]
        },
        appData: 'localData',
        appVersion:'1.0',
        percent:5,
        percent2:15,
    },
    onCreate() {
        console.info('AceApplication onCreate===================================');
    },
    onInit() {
        console.info('onInit start==================================')
        this.title = this.$t('strings.world');
        this.appData = this.$app.$def.globalData.appData;
        this.appVersion = this.$app.$def.globalData.appVersion;
        console.info('showData1:' + this.data1);
        console.info('showData3:' + this.data2.data3);

    },
    onReady(){
        console.info('onReady start=====================================')
//        const progress1 = this.$element('progress1'); // 获取id属性为animator的DOM元素
//        //const progress2 = this.$refs.progress1; // 获取ref属性为animator的DOM元素
//        progress1.percent = 88;
    },
    onShow(){
        console.info('onShow start====================================')
        let that = this;
        //const el = this.$refs.gameCanvas;
        //const ctx = el.getContext('2d');
        //var renderer = new THREE.WebGLRenderer( { canvas: el, context: ctx } );
        //var ctx = this.$element('gameCanvas').getContext('2d');
        
        // var img = new Image();
        // img.src = '/common/food_000.JPG';
        // img.onload = function() {
        //     console.log('Image load success');
        //     ctx.drawImage(img, 200, 200);
        // };
        // img.onerror = function() {
        //     console.log('Image load fail');
        // };
        var ii = 0;
        const progress1 = this.$element('progress1'); // 获取id属性为animator的DOM元素
        //const progress2 = this.$refs.progress1; // 获取ref属性为animator的DOM元素
        progress1.percent = 88;

        var intervalID = setInterval(function() {
            ii = ii +10;
            console.log('intervalID do very 1s=====================================.'+ii);
            const progress1 = this.$element('progress1'); // 获取id属性为animator的DOM元素
            const progress2 = this.$refs.progress1; // 获取ref属性为animator的DOM元素
            progress1.percent = ii;
            progress2.secondarypercent = ii+20;
            that.percent = ii;
            that.percent2 = ii+20;
//            that.setData({
//                percent: ii,
//                percent2:ii+20
//            })

            if(that.percent>=100)
            {
                clearInterval(intervalID);
                router.push({
                    uri: 'pages/list/index',
                });

            }
        }.bind(this), 2000);

//        router.push({
//            uri: 'pages/list/index',
//        });


        
    },
    onRestoreData: function onRestoreData(restoreData) {
        // 收到迁移数据，恢复。
        this.continueAbilityData = restoreData;
    },
    invokeGlobalMethod() {
        this.$app.$def.globalMethod();
    },
    getAppVersion() {
        this.appVersion = this.$app.$def.globalData.appVersion;
    }
}
